package HOME;
//智能控制系统
public class SmartHomeContrl {
    private static final  SmartHomeContrl ctrl = new SmartHomeContrl();
    private SmartHomeContrl(){
    }
    public static SmartHomeContrl getInstance(){
        return ctrl;
    }


    public void control(JD jd) {
        System.out.println(jd.getName() + "状态目前是："+ (jd.isStatus() ? "开着" : "关着"));
        System.out.println("开始您的操作");
        jd.press();
        System.out.println(jd.getName() + "状态已经是："+ (jd.isStatus() ? "开着" : "关着"));
    }

    public void printAllStatus(JD[] jds) {
        //根据索引遍历数组
        for (int i = 0; i < jds.length; i++) {
            //根据索引获取数组中的元素
            JD jd = jds[i];
            System.out.println(i+1 + "." + jd.getName() + "状态是：" + (jd.isStatus() ? "开着" : "关着"));
        }
    }
}
